package com.example.hp.qingyi.scenic.fragment.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.hp.qingyi.R;
import com.example.hp.qingyi.scenic.fragment.bean.LocationBean;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by asus on 2018/11/11.
 */

public class LocationAdapter extends RecyclerView.Adapter<LocationAdapter.ViewHolder> {
    private Context context;
    private LocationBean bean;

    public LocationAdapter(Context context, LocationBean bean) {
        this.context = context;
        this.bean = bean;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.location_adapter_item, parent, false);
        ViewHolder viewHolder=new ViewHolder(inflate);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Picasso.with(context).load(bean.getData().get(position).getScenecover()).into(holder.imageView);
        holder.textView.setText(bean.getData().get(position).getSname());

    }

    @Override
    public int getItemCount() {
        return bean.getData().size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView;
        TextView textView;
        public ViewHolder(View itemView) {
            super(itemView);
            imageView=itemView.findViewById(R.id.location_item_img);
            textView=itemView.findViewById(R.id.location_item_tv);
        }
    }
}
